/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.fiap.bean;

import java.awt.Component;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.validator.ValidatorException;
import javax.validation.ValidationException;

@ManagedBean(name = "usuario")
@SessionScoped
/**
 *
 * @author rm62102
 */
public class beanUsuario {

    private String nome;
    private String senha;

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public void validarSenha(FacesContext context, UIComponent component, Object value){

        
        if(!value.toString().equalsIgnoreCase("1234")){
            FacesMessage message = new FacesMessage("SENHA INVÁLIDA");
            throw new ValidatorException(message);
        }
    }

    public void validarNome(FacesContext context, UIComponent component, Object value){

        
        if(!value.toString().equalsIgnoreCase("Rodrigo")){ //a exclamação inverte o resultado!
            FacesMessage message = new FacesMessage("USUÁRIO INVÁLIDO");
            throw new ValidatorException(message);
        }
        
    }

}
